PROG=		hideo.out
HEX=		${PROG:R}.hex

APP_SRC=	app_display.c \
		app_mainmenu.c \
		app_poweron.c \
		app_poweroff.c \
		app_status.c \
		app_hqi.c \
		display_control.c
DRV_SRC=	drv_dc-motor.c \
		drv_ds1307.c \
		drv_24lcxxx.c \
		drv_keyboard.c \
		drv_lm35.c \
		drv_pcd8544.c \
		drv_ps2.c \
		drv_ps2_mouse.c \
		drv_pwm.c \
		drv_stepper-motor.c \
		drv_videocontroller.c
CONTRIB_SRC=	a2d.c \
		i2c.c
OS_SRC=		buffer.c \
		clist.c \
		eventmanager.c \
		hideo.c \
		hqi_control.c \
		lcd.c \
		menus.c \
		scheduler.c \
		windowmanager.c

SRCS=		${APP_SRC} ${DRV_SRC} ${OS_SRC} ${CONTRIB_SRC}

CC=		avr-gcc
MACHINE_ARCH=	arm
CFLAGS=		-funsigned-bitfields -fpack-struct -fshort-enums -std=gnu99 -mmcu=atmega32 -mcall-prologues -Wall -Os -DF_CPU=8000000UL
LDFLAGS=	-mmcu=atmega32

NO_MAN=

# [ Avrdude configuration ]

PROGRAMMER?=	stk200
MCU?=		m32

# [ System utilities ]

SUDO?=		sudo
CTAGS=		ctags

# [ Targets ]

all: ${HEX}

${HEX}: ${PROG}
	avr-objcopy -R .eeprom -O ihex ${.ALLSRC} ${.TARGET}

flash: ${HEX}
	${SUDO} avrdude -p ${MCU} -c ${PROGRAMMER} -U flash:w:${HEX}:i

ALLHC!= ls *.[hc]
reindent:
.for SRC in ${ALLHC}
	@sed -I '' -e 's///' -e 's#//[ 	]*\(.*\)#/* \1 */#g' ${SRC}
	@indent -cli1 -nfc1 ${SRC} && rm ${SRC}.BAK
.endfor

.include <bsd.prog.mk>
